<?php
	$TEMP->set_file(array('handle' => DIR_VIEW_REGISTRAR . 'postAcademicCalendar.html'));
	
	#CONTROLLER
		include DIR_MODEL		. "announcementMod.php";
		include DIR_CONTROLLER	. "announcementCon.php";
	
	$ANNOUNCE 	= new WS_AnnouncementCon();
	$AID 		= _GET('aid');
	
	if ( isset($_POST['subButton']) ) {
		
		$if_error		= 0;
		$txttitle		= _POST('txttitle');
		$txtdescription	= _POST('txtdescription'); 
		$link 			= time();
		
		if ( empty($txttitle) )			{ $if_error++; $_txttitle 		= REQ_FIELD; }
		if ( empty($txtdescription) )	{ $if_error++; $_txtdescription = REQ_FIELD; }
		
		if ( $if_error == 0 ) {
			
			$strArray = array('announce_title' 	=> firstUpperCase($txttitle),
							  'announce_desc' 	=> $txtdescription,
							  'announce_li'		=> $link,
							  'dept_idFK' 		=> 0,
							  'academic' 		=> 1);
			if ( empty($AID) )
				$ANNOUNCE->insertAnnouncementActivities($strArray);
			else
				$ANNOUNCE->updateAnnouncementActivities($strArray, $AID);
			
			redirect('?page=AcademicCalendar');
		}
	}
	else {
		$getAnnouncement = $ANNOUNCE->getAnnouncement($AID);

		$txttitle 		= $getAnnouncement['announce_title'];
		$txtdescription = $getAnnouncement['announce_desc'];
		
	}
	
	
	$TEMP->set_var(array('reg_sub_menu'		=> $pageLib->registrarSubMenu(DIR_IMAGES),
						 'w_title' 			=> $_txttitle,
						 'w_desc' 			=> $_txtdescription,
						 'txttitle' 		=> $txttitle,
						 'txtdescription' 	=> $txtdescription
						));
?>